var tp = '15%'
var leg1 = 15
var rt = '6%'
var lf = '10%'
if (window.screen.width < 1441) {
	tp = '25%'
	leg1 = 5
	rt = '3%'
}
if (window.screen.width < 1401) {
	lf = '5%'
	rt = '1%'
}

function echart1(edata) {
	var myChart1 = echarts.init(document.getElementById('echart1'));
	option1 = {
		title: {
			text: '分类次数',
			x: '48%',
			y: "35%",
			textAlign: 'center',
			textStyle: {
				fontSize: 18,
				color: ['#a0d6ff']
			}
		},
		tooltip: { //提示框，可以在全局也可以在
			trigger: 'item', //提示框的样式
			formatter: function(data) {
				return data.name + " : " + data.value;
			},
			textStyle: {
				align: 'center'
			},
			backgroundColor: 'rgba(0,0,0,0.7)'
		},
		legend: [{
				x: 'center',
				bottom: '5%',
				data: edata['areas'],
				itemGap: 20,
				itemWidth: 14,
				itemHeight: 14,
				fontSize: 16,
				textStyle: {
					color: '#a0d6ff'
				}
			}
		],
		color: ['#128943', '#af3b14', '#2a39c3', '#a4224a', '#b28f13', '#0d8888'],
		series: [{
			name: '分类次数',
			type: 'pie', //环形图的type和饼图相同
			center: ['50%', '45%'],
			startAngle: 15,
			radius: ['42%', '55%'], //饼图的半径，第一个为内半径，第二个为外半径
			avoidLabelOverlap: false,
			labelLine: {
				normal: {
					length: 15,
					length2: 80,
					lineStyle: {
						color: '#b4e4ff'
					}
				}

			},
			label: {
				normal: {
					formatter: '{b|{b}:}{c}\n{per|{d}%} ',
					align: 'center',
					fontSize: 12,
					fontFamily: '黑体',
					padding: [0, -80],
					height: 40,
					lineHeight: 20,
					rich: {
						per: {
							fontSize: 12,
							align: 'center',
							color: "#b4e4ff"
						}
					},
					textStyle: {
						fontSize: 12,
						color: "#b4e4ff"
					},
				}
			},
			data: edata['all']
		}]
	};
	myChart1.setOption(option1);
}


function echart2(edata) {
	var myChart2 = echarts.init(document.getElementById('echart2'));
	option2 = {
		tooltip: {
			trigger: 'axis',
			backgroundColor: 'rgba(0,0,0,0.7)',
			formatter(params) {
				return params[0].name + '<br/>总量：' + Number(params[0].value + params[1].value + params[2].value + params[3].value) +
					'<br/>' +
					params[0].seriesName + '：' + params[0].value + '<br/>' + params[1].seriesName + '：' + params[1].value + '<br/>' +
					params[2].seriesName + '：' + params[2].value + '<br/>' + params[3].seriesName + '：' + params[3].value;
			}
		},
		grid: {
			top: '15%',
			bottom: '10%',
			left: '3%', //左边距
			right: '25%', //走边距
			containLabel: true
		},
		legend: {
			orient: 'vertical',
			data: edata['names'],
			textStyle: {
				color: '#69b8ff',
				fontSize: 16,
				padding: [0, 0, 0, 5]
			},
			right: '7%',
			top: '35%',
			itemGap: 8,
			itemWidth: 14,
			itemHeight: 14
		},
		xAxis: [{
			type: 'category',
			data: edata['times'],
			axisPointer: {
				type: 'shadow'
			},
			axisLabel: {
				formatter: function(params) {
					params = params.replace(/\-+/g, "\n")
					return params
				},
				textStyle: {
					color: '#21c6ed', //坐标的字体颜色
					top: 20,
					lineHeight: 14,
					fontSize: 10
				}
			},
			axisLine: {
				show: false,
				labelLine: false,
				lineStyle: {
					color: '#2768a5',
					width: 2, //这里是坐标轴的宽度,可以去掉
				}
			}
		}],
		yAxis: [{
			type: 'value',
			name: '',
			nameTextStyle: {
				color: '#21c6ed'
			},
			axisLabel: {
				textStyle: {
					color: '#21c6ed', //坐标的字体颜色
				},
				formatter: '{value}'
			},
			splitLine: {
				show: false
			},
			axisLine: {
				show: false,
				lineStyle: {
					color: '#2768a5',
					width: 2, //这里是坐标轴的宽度,可以去掉
				}
			},
			splitArea: {
				show: true,
				areaStyle: {
					color: ['rgba(27,118,211,0.2)', 'rgba(27,118,211,0.1)']
				}
			}
		}],
		series: [{
				name: edata?edata['names'][0]:'',
				type: 'bar',
				barWidth: '10%',
				data: edata['data1'],
				itemStyle: {
					normal: {
						//这里是重点
						color: '#af3b14'
					}
				}
			},
			{
				name: edata?edata['names'][1]:'',
				type: 'bar',
				barWidth: '10%',
				data: edata['data2'],
				itemStyle: {
					normal: {
						//这里是重点
						color: '#b17706'
					}
				}
			},
			{
				name: edata?edata['names'][2]:'',
				type: 'bar',
				barWidth: '10%',
				data: edata['data3'],
				itemStyle: {
					normal: {
						//这里是重点
						color: '#128943'
					}
				}
			},
			{
				name: edata?edata['names'][3]:'',
				type: 'bar',
				barWidth: '10%',
				data: edata['data4'],
				itemStyle: {
					normal: {
						//这里是重点
						color: '#128943'
					}
				}
			}
		]
	};
	myChart2.setOption(option2);
}

function echart3(edata) {
	var myChart3 = echarts.init(document.getElementById('echart3'));
	option3 = {
		tooltip: { //提示框，可以在全局也可以在
			trigger: 'item', //提示框的样式
			formatter: function(data) {
				return data.name + " : " + data.value;
			},
			textStyle: {
				align: 'center'
			},
			backgroundColor: 'rgba(0,0,0,0.7)'
		},
		legend: {
			orient: 'vertical',
			data: edata['areas'],
			textStyle: {
				color: '#69b8ff',
				fontSize: 16,
				padding: [0, 0, 0, 5]
			},
			left: lf,
			top: '35%',
			itemGap: 8,
			itemWidth: 14,
			itemHeight: 14
		},
		color: ['#0d8888', '#ab181f', '#af3b14', '#398912'],
		series: [{
			name: '',
			type: 'pie', //环形图的type和饼图相同
			center: ['65%', '58%'],
			startAngle: 15,
			radius: ['42%', '55%'], //饼图的半径，第一个为内半径，第二个为外半径
			avoidLabelOverlap: false,
			labelLine: {
				normal: {
					length: leg1,
					length2: 60,
					lineStyle: {
						color: '#b4e4ff'
					}
				}

			},
			label: {
				normal: {
					formatter: '{b|{b}:}{c}\n{per|{d}%} ',
					align: 'center',
					fontSize: 12,
					fontFamily: '黑体',
					padding: [0, -60],
					height: 40,
					lineHeight: 20,
					rich: {
						per: {
							fontSize: 12,
							align: 'center',
							color: "#b4e4ff"
						}
					},
					textStyle: {
						fontSize: 12,
						color: "#b4e4ff"
					},
				}
			},
			data: edata['all']
		}]
	};
	myChart3.setOption(option3);
}


function echart4(edata) {
	var myChart4 = echarts.init(document.getElementById('echart4'));
	option4 = {
		tooltip: {
			trigger: 'item',
			formatter: '{a} <br/>{b} : {c} ({d}%)'
		},
		legend: {
			orient: 'vertical',
			data: edata['names'],
			textStyle: {
				color: '#69b8ff',
				fontSize: 16,
				padding: [0, 0, 0, 5]
			},
			right: rt,
			top: '35%',
			itemGap: 8,
			itemWidth: 14,
			itemHeight: 14
		},
		color: ['#1165b2', '#0d8888', '#70980c', '#af620f'],
		series: [{
			name: '分类占比',
			type: 'pie',
			radius: [10, 80],
			center: ['35%', '50%'],
			roseType: 'area',
			labelLine: {
				normal: {
					length: leg1,
					length2: 50,
					lineStyle: {
						color: '#b4e4ff'
					}
				}

			},
			label: {
				normal: {
					formatter: '{b|{b}}\n{per|{d}%} ',
					align: 'center',
					fontSize: 12,
					fontFamily: '黑体',
					padding: [0, -50],
					height: 40,
					lineHeight: 20,
					rich: {
						per: {
							fontSize: 12,
							align: 'center',
							color: "#b4e4ff"
						}
					},
					textStyle: {
						fontSize: 12,
						color: "#b4e4ff"
					},
				}
			},
			data: edata['all']
		}]
	};
	myChart4.setOption(option4);
}


function echart5(edata) {
	var myChart5 = echarts.init(document.getElementById('echart5'));
	option5 = {
		tooltip: {
			trigger: 'axis',
			backgroundColor: 'rgba(0,0,0,0.7)',
			formatter: '{b} : {c}',
			axisPointer: {
				type: 'none'

			}
		},
		grid: {
			top: '35%',
			bottom: '5%',
			left: '10%', //左边距
			right: '10%', //走边距
			containLabel: true
		},
		xAxis: [{
			type: 'category',
			data: edata['areas'],
			axisLabel: {
				textStyle: {
					color: '#88c3ff', //坐标的字体颜色
				},
				// formatter: '{value}w'
			},
			axisLine: {
				show: true,
				labelLine: false,
				lineStyle: {
					color: '#2768a5',
					width: 1, //这里是坐标轴的宽度,可以去掉
				}
			}
		}],
		yAxis: [{
			type: 'value',
			name: '',
			nameTextStyle: {
				color: '#21c6ed'
			},
			axisLabel: {
				textStyle: {
					color: '#88c3ff', //坐标的字体颜色
				},
				formatter: function(value) {
					return (value > 99) ? (value / 100) + 'w' : value;
				},
				// formatter: '{value}w'
			},
			splitLine: {
				show: false
			},
			axisLine: {
				show: true,
				lineStyle: {
					color: '#2768a5',
					width: 1, //这里是坐标轴的宽度,可以去掉
				}
			},
			splitArea: {
				show: true,
				areaStyle: {
					color: ['rgba(27,118,211,0.2)', 'rgba(27,118,211,0.1)']
				}
			}
		}],
		series: [{
			name: '',
			type: 'bar',
			barWidth: '50%',
			data: edata['nums'],
			label: {
				show: true,
				position: 'top',
				formatter: function(params) {
					return '{color1|' + params.value + '}\n{jt|}';
				},
				rich: {
					color1: {
						backgroundColor: 'rgba(39,77,176,0.5)',
						color: '#88c3ff',
						padding: 6,
						borderRadius: 5
					},
					jt: {
						height: 4,
						width: 8,
						backgroundColor: {
							image: './img/jian.png'
						},
						align: 'center'
					}
				},

			},
			itemStyle: {
				normal: {
					color: new echarts.graphic.LinearGradient(
						0, 0, 0, 1,
						[{
								offset: 0,
								color: '#10a3ba'
							}, //柱图渐变色
							{
								offset: 1,
								color: '#18398e'
							}, //柱图渐变色
						]
					)
				}
			}
		}]
	};
	myChart5.setOption(option5);
}




